package com.yb.core.util;

import cn.hutool.crypto.asymmetric.RSA;
import com.yb.core.constant.SecureConstant;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Copyright (C), 2022-2022, 姚兵
 * Author: 32210
 * Date: 2022/12/9 19:39
 * FileName: DecryptUtil
 * Description:
 */

@Component
@Slf4j
@Data
public class DecryptUtil {

    @Autowired
    private RSA rsaLogin;

    public String decrypt(String enstr,SecureConstant.Algorithm algorithm){
        switch (algorithm){
            case RSA:
                return YbSecureUtil.decryptRSAPrivate(rsaLogin,enstr);
            default:
                return enstr;
        }
    }
}
